﻿using System;
using System.Web.UI.WebControls;
using Bingosoft.Modules.SecurityConsole.User;
using Bingosoft.Web.Utils;

namespace Bingosoft.WebApp.Modules.SecurityConsole.User
{
    public partial class PasswordReset : System.Web.UI.BasePage
    {
        private UserService _userServie;
        private UserService UserService
        {
            get
            {
                return _userServie ??
                       (_userServie = ObjectHelper.GetObject<UserService>());
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ResetPassword(object sender, EventArgs e)
        {
            TextBox userIdTextBox = (TextBox) ControlHelper.FindControl(this.SmartFormView1, "Id");
            TextBox passwordTextBox = (TextBox)ControlHelper.FindControl(this.SmartFormView1, "Password");
            TextBox confirmTextBox = (TextBox)ControlHelper.FindControl(this.SmartFormView1, "ConfirmPassword");

            if (confirmTextBox.Text.Equals(passwordTextBox.Text))
            {
                this.UserService.ResetUserPassword(userIdTextBox.Text, passwordTextBox.Text);
                ScriptHelper.CloseDialog(this, "true");
            }
            else
            {
                ScriptHelper.Alert(this,"密码不一致，请重新填写！");
            }
        }
    }
}